package top.csy8888.ch08.service;

import lombok.RequiredArgsConstructor;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;
import top.csy8888.ch08.config.RabbitConfig;

import java.util.UUID;

/**
 * @author CSY
 * @date 2025 - 10 - 16
 */
@Service
@RequiredArgsConstructor
public class ProducerService {
    private final RabbitTemplate rabbitTemplate;

    public void send(String message) {
        CorrelationData cdata = new CorrelationData(UUID.randomUUID().toString());
        rabbitTemplate.convertAndSend(RabbitConfig.EXCHANGE_NAME, RabbitConfig.ROUTING_KEY, message, cdata);
    }
}
